<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>

<script>
    var arr=[8,2,3,7,1,4,9,5,6,0];
    function quick(arr){
        console.info('input:',arr);
        if(arr.length<2){
            console.warn('output:',arr);
            return arr;
        }
        var pos=arr.length/2| 0,mid=arr.splice(pos,1)[0],left=[],right=[];

        console.log('pos mid:',pos,mid);
        for(var i= 0;i<arr.length;i++){
            if(arr[i]<mid){
                left.push(arr[i]);
            }else{
                right.push(arr[i]);
            }
        }
        console.log('left:',left);
        console.log('right:',right);
        return quick(left).concat(mid,quick(right));
    }

    console.info(quick(arr));
</script>

</body>
</html>